<?php

class Text
{
    static function random($len = 8, $type = 'alnum')
    {
        switch($type)
        {
            case 'secret':
                $seek = '1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM*~!@#$%^&*-+_=|,>';
                break;
            case 'alphabet' :
                $seek = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM';
                break;
            case 'lower' :
                $seek = 'qwertyuiopasdfghjklzxcvbnm';
                break;
            case 'upper' :
                $seek = 'QWERTYUIOPASDFGHJKLZXCVBNM';
                break;
            case 'num' :
                $seek = '0123456789';
                break;
            case 'alnum' :
            default :
                $seek = '1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM';
        }

        $max = strlen($seek) - 1;
        $ret = '';
        for ($i = 0; $i < $len; ++$i)
        {
            $ret .= substr($seek, mt_rand(0, $max), 1);
        }
        return $ret;

    }

}
